package com.tanhua.server.exceptions;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

@ControllerAdvice
public class BasicExceptionAdvice {

    @ExceptionHandler(TanhuaException.class)
    public ResponseEntity tanhuaException(TanhuaException e){
        e.printStackTrace();
        System.out.println("进入了统一异常处理器的tanhuaException方法");
        return ResponseEntity.status(e.getStatusCode()).body(e.getMessage());
    }

    @ExceptionHandler(Exception.class)
    public ResponseEntity exception(Exception e){
        e.printStackTrace();
        System.out.println("进入了统一异常处理器的exception方法");
        return ResponseEntity.status(500).body(e.getMessage());
    }
}
